<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <title>开发</title>
    <link rel="stylesheet" type="text/css" href="../css/api.css"/>
    <link rel="stylesheet" type="text/css" href="../css/style.css"/>
    <style>
        body{background:#EFEFF4;}
.topbar {background: #ec6d65; height:35px;position:relative}    
        
     .whitebar {}   
     .titlebar{background-color: #ec6d65;width:100%;width: 100%;height:40px; position: fixed;top:0;left:0;z-index: 10000;}
     #localrefresh {display:none;float: right; width: 40px; padding: 5px 10px;} 
     #field1::-webkit-input-placeholder { color:#fff; } 
     #field1 {height: 30px; line-height: 30px; width: 70%;} 
    
     .swipe {line-height:35px;height:35px;margin-right: 10px;color: #FF8400;}   
     .back {float: right;position:absolute;right:0;top:2px;}    
     .back span {display:inline-block;height:18px;margin-top: 5px;margin-right: 10px;margin-left:10px;color:#fff;}   
     .topbar .title {line-height:35px;height:35px;text-align: center;font-size: 16px;color:#fff;}   
#add {
    list-style: none;
    padding: 0;
    margin: 0;
    width: 100%;
    text-align: left;
    padding: 60px 10px 10px;
    background: #EFEFF4;
    box-sizing: border-box;
}
.sharecar_data_items {
    background: #fff;
    border-radius: 5px;
    margin-top: 10px;
}
.sharecar_data_items a {
    display: block;
    color: #333;
    font-size: 17px;
}
.sharecar_data_items .order_list {
    position: relative;
    overflow: hidden;
    line-height: 30px;
    font-size: 14px;
}
.sharecar_data_items .order_title {
    color: #fff;
    background: #1BA6E0;
    border-top-left-radius: 5px;
    border-top-right-radius: 5px;
}
.sharecar_data_items .order_content {
    font-size: 14px;
}
.sharecar_data_items .order_bottom {
    font-size: 14px;
}
.sharecar_data_items .c_l {
    width: 70%;
    float: left;
    padding-left: 10px;
}
.sharecar_data_items .c_r {
    position: absolute;
    display: block;
    right: 10px;
    height: 30px;
    line-height: 30px;
}
.sharecar_data_items .datas_item {
    position: relative;
}
.sharecar_data_items .datas_item .c_r {
    position: absolute;
    height: 60px;
    line-height: 60px;
    font-size: 20px;
}





.data_items_pt {
    background: #fff;
    border-radius: 5px;
    margin-top: 10px;
}
.data_items_pt a {
    display: block;
    color: #333;
    font-size: 17px;
}
.data_items_pt .order_list {
    position: relative;
    overflow: hidden;
    line-height: 30px;
    font-size: 14px;
}
.data_items_pt .order_title {
    color: #fff;
    background: #ec6d65;
    border-top-left-radius: 5px;
    border-top-right-radius: 5px;
}
.data_items_pt .order_content {
    font-size: 14px;
}
.data_items_pt .order_bottom {
    font-size: 14px;
}
.data_items_pt .c_l {
    width: 70%;
    float: left;
    padding-left: 10px;
}
.data_items_pt .c_r {
    position: absolute;
    display: block;
    right: 10px;
    height: 30px;
    line-height: 30px;
}
.data_items_pt .order_list .data_item {
    position: relative;
    overflow: hidden;
}
.data_items_pt .order_content .data_item {
    margin-top: 0;
}

.data_items_pt .order_detail {
    position: absolute;
    top: 0;
    left: 0;
    font-size: 16px;
    width: 100%;
    min-height: 100%;
    padding-top: 10px;
    z-index: 40;
    display: none;
}
.data_items_pt .order_detail_wrap {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    min-height: 100%;
    z-index: 41;
    background: rgba(0,0,0,.7);
}
.data_items_pt .order_detail_content {
    padding: 10px;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 42;
}
.data_items_pt .item_data {
    background: #fff;
    margin-top: 10px;
    border-radius: 5px;
    line-height: 30px;
    color: #666;
    width: 100%;
    overflow: hidden;
}
.data_items_pt .order_list {
    position: relative;
    overflow: hidden;
    line-height: 30px;
    font-size: 14px;
}
.data_items_pt .order_title {
    color: #fff;
    background: #ec6d65;
    border-top-left-radius: 5px;
    border-top-right-radius: 5px;
}
.data_items_pt .padding_contn {
    min-height: 120px;
    max-height: 330px;
    overflow: hidden;
}
.data_items_pt .padding_contn {
    padding: 10px;
}
.data_items_pt .order_detail_rule {
    font-size: 14px;
    line-height: 24px;
    color: #8B8A8A;
    margin: 10px 0 0;
    padding: 0 10px;
}
.list_button{width:100%;height:45px;text-align: center;}
.list_button button{width:80px;height:35px;background: #ec6d65;color:#fff;font-size: 16px;margin:0 auto;border-radius:3px;}
.list_button.buttoncc button{background: #1BA6E0;}
    </style>
}
</head>
<body>
    <div id="thridHeader" class="titlebar"> 
        <div class="topbar whitebar">   
          <div class="title" id="id_title"></div>
          <div class="back" tapmode onclick="closeWindows();"><span>返回</span></div>      
        </div>  
      </div>
    <div id="add"></div>
</body>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="../script/urlpath.js"></script>
<script>
    function closeWindows(){
        api.closeFrame();
    }
    apiready = function () {
        var thridHeader = $api.byId('thridHeader'); 
        $api.fixIos7Bar(thridHeader); 
        $api.fixStatusBar(thridHeader);
        var thridHeader = $api.offset(thridHeader);
        var mobile_input = api.pageParam.mobile_input;
        seacrMobileList(mobile_input);
    }
    function seacrMobileList(mobile_input){
        $api.html($api.byId("add"),'');
        api.showProgress({
            style: 'default',
            animationType: 'fade',
            title: '努力加载中...',
            text: '请稍候...',
            modal: false
        });
        api.ajax({
            url: URLpath+'/ajax/call/vender_admin/verify_info_mobile',
            method: 'post',
            data: {
                values: { 
                    "mobile": mobile_input
                }
            },
            timeout:5
        },function(ret, err){
            api.hideProgress();

            if (ret) {
                if(!ret || ret.errno ){
                    api.toast({
                        msg: ret.errmsg,
                        duration: 2000,
                        location: 'middle'
                    });
                }else{
                    $api.html($api.byId('id_title'),ret.nickname)
                    $api.css($api.byId("search_mobile_list"),'display:block;');
                    if(ret.share_card_verify != undefined && ret.share_card_verify.length > 0){
                        for(var i=0; i< ret.share_card_verify.length; i++){
                            var res = ret.share_card_verify;
                                var trs = ''; 
                                    trs += '<div class="sharecar_data_items" order_id="1003894">'; 
                                    trs += '<a href="javascript:void(0);" class="order_list_btn">'; 
                                    trs += '<div class="order_list order_title">'; 
                                    trs += '<div class="c_l">'+res[i].goods_name+'</div>'; 
                                    trs += '<span class="c_r">'+res[i].total_count+'次卡</span>'; 
                                    trs += '</div>'; 
                                    trs += '<div class="order_list order_content">'; 
                                    trs += '<div class="datas_item">'; 
                                    trs += '<div class="c_l"><p>商家:'+res[i].vender_name+'</p><p>电话:'+res[i].user_mobile+'</p></div>'; 
                                    trs += '<span class="c_r">剩余:'+res[i].left_count+'次</span>'; 
                                    trs += '</div>'; 
                                    trs += '</div>'; 
                                    trs += '<div class="order_list order_bottom">'; 
                                    var dateString = res[i].expire_date;
                                    var pattern = /(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/;
                                    var formatedDate = dateString.replace(pattern, '$1-$2-$3 $4:$5:$6');
                                    trs += '<div class="c_l">有效期至：'+formatedDate+'</div>'; 
                                    trs += '<span class="c_r"></span>'; 
                                    trs += '</div>'; 
                                    trs += "<div class='list_button buttoncc'><button onclick='useVerifyFnBegin("+JSON.stringify(res[i].verify_sn)+")'>使用一次</button></div>";
                                    trs += '</a>'; 
                                    trs += '</div>'; 
                                $api.append($api.byId("add"),trs);
                            }
                    }
                    if(ret.ticket_verify != undefined && ret.ticket_verify.length > 0){
                        for(var j = 0; j < ret.ticket_verify.length; j++){

                            var resc = ret.ticket_verify;
                            var trs = ""; 
                                trs += "<div class='data_items_pt' order_id="+resc[j].order_id+">";
                                trs += "<a href='javascript:void(0);' class='order_list_btn'>";
                                trs += "<div class='order_list order_title'>";
                                trs += "<div class='c_l'>" +resc[j].goods_name+"</div>";
                                trs += "<span class='c_r'></span>";
                                trs += "</div>";
                                trs += "<div class='order_list order_content'>";
                                trs += "<div class='data_item'>";
                                trs += "<div class='c_l'>订单号:"+resc[j].order_sn+"</div>";
                                // trs += "<span class='c_r'>支付:"+res[j].pay_fee+"</span>";
                                trs += "</div>";
                                trs += "<div class='data_item'>";
                                trs += "<div class='c_l'>电话:"+resc[j].mobile+"</div>";
                                trs += "<span class='c_r'></span>";
                                trs += "</div>";
                                trs += "</div>";
                                trs += "<div class='order_list order_bottom'>";
                                var dateString = resc[j].add_time;
                                var pattern = /(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/;
                                var formatedDate = dateString.replace(pattern, '$1-$2-$3 $4:$5:$6');
                                trs += "<div class='c_l'>"+formatedDate+"</div>";
                                trs += "<span class='c_r'>金额:"+resc[j].goods_price+"元</span>";
                                trs += "</div>";
                                trs += "<div class='list_button'><button onclick='useVerifyFnBegin("+JSON.stringify(resc[j].card_sn)+")'>使用</button></div>";

                                trs += "</a>";
                                trs += "</div>";
                            $api.append($api.byId("add"),trs);
                        }
                    }
                    
                    
                }
            } else {
                // api.confirm({
                //     title: '系统提示',
                //     msg: '网络请求超时，下拉刷新试试？',
                //     buttons: ['确定']
                // },function( ret, err ){
                    
                // });
            }
        });
    }

                    function useVerifyFnBegin(verify_snes){

                        api.confirm({
                            title: '系统提示:',
                            msg: '确定要进行核销吗？',
                            buttons: ['取消', '确定']
                        },function( ret, err ){
                            if( ret ){
                                 if(ret.buttonIndex == "1"){
                                    
                                 }else{
                                    useVerifyFn(verify_snes);
                                 }
                            }else{
                                 // alert( JSON.stringify( ret ) );
                            }
                        });
                    }
                    function useVerifyFn(num){
                        api.showProgress({
                            style: 'default',
                            animationType: 'fade',
                            title: '努力加载中...',
                            text: '请稍候...',
                            modal: false
                        });
                        api.ajax({
                            url: URLpath+'/ajax/call/vender_admin/verify_use',
                            method: 'post',
                            data: {
                                values: { 
                                    "verify_sn":num
                                }
                            },
                            timeout:5
                        },function(ret, err){
                            api.hideProgress();
                            if (ret) {
                                if(!ret || ret.errno ){
                                    // alert(ret.errmsg);
                                    api.toast({
                                        msg: ret.errno+':'+ret.errmsg,
                                        duration: 1000,
                                        location: 'middle'
                                    });
                                    setTimeout(function(){
                                        closeWindows();
                                    },1000);
                                }else{
                                    api.toast({
                                        msg: '核销成功',
                                        duration: 800,
                                        location: 'middle'
                                    });
                                    // closeWindows();
                                    setTimeout(function(){
                                        closeWindows();
                                    }, 800);
                                }
                            } else {
                                api.confirm({
                                    title: '系统提示',
                                    msg: '网络请求超时，下拉刷新试试？',
                                    buttons: ['确定']
                                },function( ret, err ){
                                    
                                });
                            }
                        });
                    }






</script>
</html>